// @author: caoshi
// @date: 2021-05-11 20:09
package main

import (
	"html/template"
	"net/http"
)

func welcome(w http.ResponseWriter, r *http.Request) {
	temp, _ := template.ParseFiles("view/index.html")

	// 传递切片数据
	// arr := []string{"aaa", "bbb", "ccc"}

	// 传递map
	m := map[string]string{"key1": "value1", "key2": "value2", "key3": "value3"}


	temp.Execute(w, m)
}

func main() {
	server := http.Server{Addr: "localhost:8090"}
	http.HandleFunc("/", welcome)
	server.ListenAndServe()
}
